#pragma once

#include "Location.h"
#include "Command.h"
#include <string>
#include <vector>

//The ResourceManager handles the loading and saving of data. Uses the singleton pattern.
class ResourceManager
{
public:
	static ResourceManager* GetInstance();
	Location* GetLocation(int index) { return fLocations[index]; }

private:
	static ResourceManager* instance;
	
	char* LocationsFile;
	char* CommandsFile;
	vector<Location*> fLocations;	// locations from file
	vector<Command*> fCommands;		// commands from file

	void LoadLocations();
	void SaveLocations() const;

	void LoadCommands();
	void SaveCommands() const;

	template <class T> void ClearVector(vector<T*> *vec) const 
	{
		while ( !vec->empty() ) { delete vec->back(); vec->pop_back(); }
	}

	ResourceManager(void);
	~ResourceManager(void);
};
